package com.pls.main;

import com.pls.data.EmployeeSeatData;
import com.pls.entity.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.util.List;

public class Program {
	@SuppressWarnings("unused")
	public static void main(String[] args) {
		
		BufferedReader reader = null;
		int command = 0;
		Menu menu = new Menu();
		MainProgram program = new MainProgram();

		while (command != menu.getMenuList().size()) {
			command = menu.populateMenuList(reader);
			try {
				program.executeCommand(command, reader);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			// try {
			// command = menu.populateMenuList(reader);
			// program.executeCommand(command, reader);
			// } catch (Exception e) {
			// // System.out.println("Something Went Wrong!");
			// // System.out.println();
			// // continue;
			// }

		}
		if (reader != null) {
			try {
				reader.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
/*		Locator locator2 = new Locator();
		
		int employeeid = 110024;
		String newSeatCode = null;
		
		EmployeeSeat empseat2 = locator2.searchEmployeeSeat(employeeid);
		
		System.out.println("EmployeeSeat2: " + empseat2.getSeatCode());
		
		int seatId = empseat2.getSeatID();
		String prevSeatCode = empseat2.getSeatCode();
		
		if (newSeatCode.isEmpty() != false ){
			
		}
		else {
			EmployeeSeatModifier empSeatMod = new EmployeeSeatModifier();
			
			
			int empSeat1 = empSeatMod.updateEmployeeSeat(employeeid, prevSeatCode, seatId);
			
			System.out.println("UpdateEmployeeSeatCount: " + empSeat1);
			
		}
*/			

		/*
		 * Locator locator2 = new Locator();
		 * 
		 * int employeeid = 110024; String newSeatCode = null;
		 * 
		 * EmployeeSeat empseat2 = locator2.searchEmployeeSeat(employeeid);
		 * 
		 * System.out.println("EmployeeSeat2: " + empseat2.getSeatCode());
		 * 
		 * int seatId = empseat2.getSeatID(); String prevSeatCode =
		 * empseat2.getSeatCode();
		 * 
		 * if (newSeatCode.isEmpty() != false ){
		 * 
		 * } else { EmployeeSeatModifier empSeatMod = new
		 * EmployeeSeatModifier();
		 * 
		 * 
		 * int empSeat1 = empSeatMod.updateEmployeeSeat(employeeid,
		 * prevSeatCode, seatId);
		 * 
		 * System.out.println("UpdateEmployeeSeatCount: " + empSeat1);
		 * 
		 * }
		 */

		// EmployeeSeatModifier empSeatMod = new EmployeeSeatModifier();
		//
		// int empSeat1 = empSeatMod.updateEmployeeSeat(110003, "PTC12FA1-5");
		//
		// System.out.println("UpdateEmployeeSeatCount: " + empSeat1);

//		UpdateProcess:
		
/*		int employeeId = 110003;
		String newSeatCode ="PTC12FA1-5";
		
		EmployeeSeatData empSeatData = new EmployeeSeatData();
		
		EmployeeSeatData empSeatData2 = new EmployeeSeatData();
		
		Boolean isSeatCodeExist = empSeatData.validateSeatCodeExist(newSeatCode);
		
		List<EmployeeSeat> empSeatList = empSeatData2.selectEmployeeSeatInformation(newSeatCode, isSeatCodeExist); 
		
		//Get EmployeeSeatDetails
		for (EmployeeSeat employeeSeat : empSeatList) {
		
			EmployeeSeatData empSeatData3 = new EmployeeSeatData();
			
			EmployeeSeat empSeat2 = new EmployeeSeat();
			empSeat2 = empSeatData3.getEmployeeSeatDetails(employeeSeat.getEmployee().getId());
			int tableEmployeeId = empSeat2.getEmployee().getId(); 	
		
			int empSeat1 = 0;
			
			if (isSeatCodeExist == true && tableEmployeeId == 0){
				//update
				EmployeeSeatModifier empSeatMod = new EmployeeSeatModifier(); 		
				
				empSeat1 = empSeatMod.updateEmployeeSeat(employeeId, newSeatCode, empSeat2.getSeatID());

				
			}
		
			if (isSeatCodeExist == true && tableEmployeeId > 0){
				//insert
				EmployeeSeatModifier empSeatMod3 = new EmployeeSeatModifier(); 		

				String locCode = newSeatCode.substring(0,3);

				String floorLevel = "";
				
				if (locCode.equals("PTC")){
					floorLevel = newSeatCode.substring(4,6);
				}
				
				if (locCode.equals("PIC")){
					floorLevel = newSeatCode.substring(3,5);
				}
				
				int empIntSeat2 = empSeatMod3.insertEmployeeSeat(employeeId, floorLevel, empSeat2, isSeatCodeExist);
			
			}	
			
		}
*/		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
//		foreach(empSeat: empSeatList){
//		
//			EmployeeSeat empSeat = new EmployeeSeat();
//			empSeat = empSeat.getEmployeeSeatDetails(employeeId);
//			int tableEmployeeId = empSeat.getEmployeeId(); 	
//		
//			if (isSeatCodeExist == true && tableEmployeeId == null) {
//				System.out.println("No occupant in the seatcode provided.")
//			}
//		
//			if (isSeatCodeExist == true && tableEmployeeId > 0){
//				//delete 
//			}	

//		} 

		/*
		 * DeleteProcess:
		 * 
		 * 
		 * int employeeId = 0; String SeatCode ="";
		 * 
		 * Boolean isSeatCodeExist = validateSeatCodeExist(newSeatCode);
		 * 
		 * List<EmployeeSeat> empSeatList =
		 * selectEmployeeSeatInformation(SeatCode, isSeatCodeExist) {
		 * 
		 * //Get EmployeeSeatDetails
		 * 
		 * foreach(empSeat: empSeatList){
		 * 
		 * EmployeeSeat empSeat = new EmployeeSeat(); empSeat =
		 * empSeat.getEmployeeSeatDetails(employeeId); int tableEmployeeId =
		 * empSeat.getEmployeeId();
		 * 
		 * if (isSeatCodeExist == true && tableEmployeeId == null) {
		 * System.out.println("No occupant in the seatcode provided.") }
		 * 
		 * if (isSeatCodeExist == true && tableEmployeeId > 0){ //delete }
		 * 
		 * }
		 */

	}

}